package ding.fram;

import java.io.File;

//递归器
public class Deeper {

    //判断这个文件夹是否是满足条件的文件夹
    private NameCreater nameCreater;

    //文件夹处理器
    private DirHandler dirHandler;

    public void setNameCreater(NameCreater nameCreater) {
        this.nameCreater = nameCreater;
    }

    public void setDirHandler(DirHandler dirHandler) {
        this.dirHandler = dirHandler;
    }
    public void read(File file) {
        File[] files = file.listFiles();
        if (files != null && files.length > 0) {
            for (File f : files) {
                read(f, file.getName());
            }
        }
    }

    public void read(File file, String mark) {
        if (file.isDirectory()) {
            String n = nameCreater.name(file.getName());
            if (n != null) {
                dirHandler.handle(n, file,mark);
            }
        }
    }

}